﻿namespace DotNetUtility.ExtensionMethods.Test
{
    using NUnit.Framework;
    using DotNetUtility.ExtensionMethods;

    [TestFixture]
    public class ObjectExtensionsTest
    {

        [Test]
        public void IsAnObjectEqualToNull()
        {
            object objectToTest = null;
            bool expectedResult = true;
            Assert.AreEqual(objectToTest.IsEqualToNull(), expectedResult);
        }

        [Test]
        public void IsAnObjectNotEqualToNull()
        {
            Person person = new Person();
            bool expectedResult = true;
            Assert.AreEqual(person.IsNotEqualToNull(), expectedResult);
        }

        [Test]
        public void IsSameTypeAs()
        {
            PersonA personA = new PersonA();
            PersonB personB = new PersonB();
            bool expectedResult = default(bool);
            Assert.AreEqual(expectedResult, personA.IsSameTypeAs(personB));
        }

        [Test]
        public void IsImplementSameInterface() 
        {
            PersonA personA = new PersonA();
            PersonB personB = new PersonB();
            bool expectedResult = true;
            Assert.AreEqual(expectedResult, personA.IsImplementSameInterface<IPerson>(personB));
        }
    }

    internal class Person
    {
        public string Name { get; set; }
    }

    public interface IPerson { string FindPersonName();}

    public class PersonA : IPerson
    {
        public string FindPersonName()
        { return "A"; }
    }
    public class PersonB : IPerson
    {
        public string FindPersonName()
        { return "B"; }
    }
    public class PersonInd
    {
        public string FindPersonName()
        { return "A"; }
    }
}


